﻿using Base.FileGateway.VisitEvent;
using Base.FileModel.UserFile;
using Base.FileService.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Interface;
using WeDonekRpc.HttpApiGateway.Response;

namespace Base.FileGateway.Api
{
    [ApiEventAttr(typeof(UserFileVisitEvent))]
    internal class UserVideoFileController : ApiController
    {
        private readonly IVideoFileService _Service;

        public UserVideoFileController ( IVideoFileService service )
        {
            this._Service = service;
        }

        [ApiPower(false)]
        [ApiRouteName("/file/user/video/thumbnail/")]
        public IResponse ReadThumbnail ()
        {
            UserFileDto file = this.RequestState.Get<UserFileDto>("file");
            FileInfo fileInfo = this._Service.GetThumbnail(file);
            return new StreamResponse(fileInfo);
        }
    }
}
